<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <form id="my-form" class="am-form tpl-form-line-form" method="post">
                    <div class="widget-body">
                        <fieldset>
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl"><{$tit}>管理</div>
                            </div>
                            <!-- <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 身份 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <{html_radios1("data[level]",$userLevels,$info.level)}>
                                </div>
                            </div> -->
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">所属身份 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <{html_radios1("data[level]",$userLevels,$info.level)}>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">用户名 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[username]"
                                           value="<?= $info['username'] ?>" placeholder="请输入用户名" >
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">登录密码 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="password" class="tpl-form-input" name="data[password]"
                                           value="" placeholder="请输入登录密码">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">真实姓名 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[realname]"
                                           value="<?= $info['realname'] ?>">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">手机 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[tel]"
                                           value="<?= $info['tel'] ?>" placeholder="请输入手机" required>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">微信授权ID </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="data[user_id]"
                                           value="<?= $info['user_id'] ?>" placeholder="微信授权ID">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">前台管理员 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <{html_radios1("data[is_admin2]",$noRadio,$info.is_admin2)}>
                                </div>
                            </div>
                            <!-- <div class="am-form-group">
                                <label class="am-u-sm-3  am-u-lg-2 am-form-label form-require"> 所属门店 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="widget-become-goods am-form-file am-margin-top-xs">
                                        <button type="button"
                                                class="j-selectUser upload-file am-btn am-btn-secondary am-radius">
                                            <i class="am-icon-cloud-upload"></i> 选择门店
                                        </button>
                                        <div class="user-list uploader-list am-cf">
                                            <{if $info['store_id']}>
                                            <div class="file-item">
                                                <?= $info['company']['name'] ?> - <?= $info['store']['name'] ?> (ID:<?= $info['store']['id'] ?>)
                                                <input type="hidden" name="data[company_id]" value="<?= $info['company']['id'] ?>">
                                                <input type="hidden" name="data[store_id]" value="<?= $info['store']['id'] ?>">
                                            </div>
                                            <{/if}>
                                        </div>
                                        <div class="am-block">
                                            <small>选择后不可更改</small>
                                        </div>
                                    </div>
                                </div>
                            </div> -->
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
                                    <button type="submit" class="j-submit am-btn am-btn-secondary">提交
                                    </button>
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- 图片文件列表模板 -->
<script id="tpl-user-item" type="text/template">
    {{ each $data }}
    <div class="file-item">
        <!-- <a href="{{ $value.avatarUrl }}" title="{{ $value.nickName }} (ID:{{ $value.store_id }})" target="_blank">
            <img src="{{ $value.avatarUrl }}">
        </a> -->
        {{ $value.company_name }} - {{ $value.name }} (ID:{{ $value.store_id }})
        <input type="hidden" name="data[company_id]" value="{{ $value.company_id }}">
        <input type="hidden" name="data[store_id]" value="{{ $value.store_id }}">
    </div>
    {{ /each }}
</script>


<script src="/static/assets/store/js/select.data.js?v=<?= $version ?>"></script>
<script>
    $(function () {

        // 选择用户
        $('.j-selectUser').click(function () {
            var $userList = $('.user-list');
            $.selectData({
                title: '选择门店',
                uri: 'store/list',
                dataIndex: 'store_id',
                done: function (data) {
                    var user = [data[0]];
                    $userList.html(template('tpl-user-item', user));
                }
            });
        });

        /**
         * 表单验证提交
         * @type {*}
         */
        $('#my-form').superForm({});

    });
</script>
